package ws;

import javax.microedition.xml.rpc.ComplexType;
import javax.microedition.xml.rpc.Element;
import javax.microedition.xml.rpc.Operation;
import javax.microedition.xml.rpc.Type;
import javax.xml.namespace.QName;
import javax.xml.rpc.JAXRPCException;

import model.MobileContent;
import model.MobileGame;

public class Service1Soap_Stub implements Service1Soap, javax.xml.rpc.Stub {
	private String[] _propertyNames;
	private Object[] _propertyValues;

	public Service1Soap_Stub() {
		_propertyNames = new String[] {ENDPOINT_ADDRESS_PROPERTY};
		_propertyValues = new Object[] {"http://wsmobileapplications.telinfor.com/wsmobileapplication.asmx"};
	}

	public void _setProperty(String name, Object value) {
		int size = _propertyNames.length;
		for (int i = 0; i < size; ++i) {
			if (_propertyNames[i].equals(name)) {
				_propertyValues[i] = value;
				return;
			}
		}
		// Need to expand our array for a new property
		String[] newPropNames = new String[size + 1];
		System.arraycopy(_propertyNames, 0, newPropNames, 0, size);
		_propertyNames = newPropNames;
		Object[] newPropValues = new Object[size + 1];
		System.arraycopy(_propertyValues, 0, newPropValues, 0, size);
		_propertyValues = newPropValues;

		_propertyNames[size] = name;
		_propertyValues[size] = value;
	}

	public Object _getProperty(String name) {
		for (int i = 0; i < _propertyNames.length; ++i) {
			if (_propertyNames[i].equals(name)) {
				return _propertyValues[i];
			}
		}
		if (ENDPOINT_ADDRESS_PROPERTY.equals(name) || USERNAME_PROPERTY.equals(name) || PASSWORD_PROPERTY.equals(name)) {
			return null;
		}
		if (SESSION_MAINTAIN_PROPERTY.equals(name)) {
			return new java.lang.Boolean(false);
		}
		throw new JAXRPCException("Stub does not recognize property: "+name);
	}

	protected void _prepOperation(Operation op) {
		for (int i = 0; i < _propertyNames.length; ++i) {
			op.setProperty(_propertyNames[i], _propertyValues[i].toString());
		}
	}

	// 
	//  Begin user methods
	// 

	public MobileGame[] getGamesByAppID(int appID) throws Exception {
		// Copy the incoming values into an Object array if needed.
		Object[] inputObject = new Object[1];
		inputObject[0] = new java.lang.Integer(appID);

		Operation op = Operation.newInstance(_qname_getGamesByAppID, _type_getGamesByAppID, _type_getGamesByAppIDResponse);
		_prepOperation(op);
		op.setProperty(Operation.SOAPACTION_URI_PROPERTY, "http://tempuri.org/wsMobile/getGamesByAppID");
		Object resultObj;
		try {
			resultObj = op.invoke(inputObject);
		} catch (Exception e) {
		throw e;
		}
		MobileGame[] result;
		// Convert the result into the right Java type.
		// Unwrapped return value
		Object[] getGamesByAppIDResultObj = (Object[]) ((Object[])resultObj)[0];
		if (getGamesByAppIDResultObj == null) {
			result = null;
		} else {
			MobileGame[] mobileGameArray;
			Object[] mobileGameObj = (Object[]) getGamesByAppIDResultObj[0];
			if (mobileGameObj == null) {
				mobileGameArray = null;
			} else {
				int mobileGameArraySize = mobileGameObj.length;
				mobileGameArray = new MobileGame[mobileGameArraySize];
				for (int mobileGameArrayIndex = 0; 
					mobileGameArrayIndex < mobileGameArraySize; 
					++mobileGameArrayIndex) {
					if (mobileGameObj[mobileGameArrayIndex] == null) {
						mobileGameArray[mobileGameArrayIndex] = null;
					} else {
						mobileGameArray[mobileGameArrayIndex] = new MobileGame();
						int a_int;
						Object gameIDObj = ((Object[])mobileGameObj[mobileGameArrayIndex])[0];
						a_int = ((java.lang.Integer)gameIDObj).intValue();
						mobileGameArray[mobileGameArrayIndex].setGameID(a_int);
						java.lang.String string;
						Object textObj = ((Object[])mobileGameObj[mobileGameArrayIndex])[1];
						string = (java.lang.String)textObj;
						mobileGameArray[mobileGameArrayIndex].setText(string);
						java.lang.String string2;
						Object CCObj = ((Object[])mobileGameObj[mobileGameArrayIndex])[2];
						string2 = (java.lang.String)CCObj;
						mobileGameArray[mobileGameArrayIndex].setCC(string2);
						java.lang.String string3;
						Object imgURLObj = ((Object[])mobileGameObj[mobileGameArrayIndex])[3];
						string3 = (java.lang.String)imgURLObj;
						mobileGameArray[mobileGameArrayIndex].setImgURL(string3);
					}
				}
			}
			return mobileGameArray;
		}
		return result;
	}

	public MobileContent[] getContentByAppID(int appID) throws java.rmi.RemoteException {
		// Copy the incoming values into an Object array if needed.
		Object[] inputObject = new Object[1];
		inputObject[0] = new java.lang.Integer(appID);

		Operation op = Operation.newInstance(_qname_getContentByAppID, _type_getContentByAppID, _type_getContentByAppIDResponse);
		_prepOperation(op);
		op.setProperty(Operation.SOAPACTION_URI_PROPERTY, "http://tempuri.org/wsMobile/getContentByAppID");
		Object resultObj;
		try {
			resultObj = op.invoke(inputObject);
		} catch (JAXRPCException e) {
			Throwable cause = e.getLinkedCause();
			if (cause instanceof java.rmi.RemoteException) {
				throw (java.rmi.RemoteException) cause;
			}
			throw e;
		}
		MobileContent result;
		// Convert the result into the right Java type.
		// Unwrapped return value
		Object[] getContentByAppIDResultObj = (Object[]) ((Object[])resultObj)[0];
		if (getContentByAppIDResultObj == null) {
			result = null;
		} else {
			result = new MobileContent();
			MobileContent[] mobileContentArray;
			Object[] mobileContentObj = (Object[]) getContentByAppIDResultObj[0];
			if (mobileContentObj == null) {
				mobileContentArray = null;
			} else {
				int mobileContentArraySize = mobileContentObj.length;
				mobileContentArray = new MobileContent[mobileContentArraySize];
				for (int mobileContentArrayIndex = 0; 
					mobileContentArrayIndex < mobileContentArraySize; 
					++mobileContentArrayIndex) {
					if (mobileContentObj[mobileContentArrayIndex] == null) {
						mobileContentArray[mobileContentArrayIndex] = null;
					} else {
						mobileContentArray[mobileContentArrayIndex] = new MobileContent();
						java.lang.String string;
						Object URLObj = ((Object[])mobileContentObj[mobileContentArrayIndex])[0];
						string = (java.lang.String)URLObj;
						mobileContentArray[mobileContentArrayIndex].setImgURL(string);
						java.lang.String string2;
						Object descripcionObj = ((Object[])mobileContentObj[mobileContentArrayIndex])[1];
						string2 = (java.lang.String)descripcionObj;
						mobileContentArray[mobileContentArrayIndex].setDescription(string2);
						boolean a_boolean;
						Object statusObj = ((Object[])mobileContentObj[mobileContentArrayIndex])[2];
						a_boolean = ((java.lang.Boolean)statusObj).booleanValue();
						mobileContentArray[mobileContentArrayIndex].setStatus(a_boolean);
					}
				}
			}
			return mobileContentArray;
		}
		return null;
	}
	// 
	//  End user methods
	// 

	protected static final QName _qname_CC = new QName("http://tempuri.org/wsMobile", "CC");
	protected static final QName _qname_Descripcion = new QName("http://tempuri.org/wsMobile", "Descripcion");
	protected static final QName _qname_GameID = new QName("http://tempuri.org/wsMobile", "GameID");
	protected static final QName _qname_ImgURL = new QName("http://tempuri.org/wsMobile", "ImgURL");
	protected static final QName _qname_MobileContent = new QName("http://tempuri.org/wsMobile", "MobileContent");
	protected static final QName _qname_MobileGame = new QName("http://tempuri.org/wsMobile", "MobileGame");
	protected static final QName _qname_Status = new QName("http://tempuri.org/wsMobile", "Status");
	protected static final QName _qname_Text = new QName("http://tempuri.org/wsMobile", "Text");
	protected static final QName _qname_URL = new QName("http://tempuri.org/wsMobile", "URL");
	protected static final QName _qname_appID = new QName("http://tempuri.org/wsMobile", "appID");
	protected static final QName _qname_getContentByAppID = new QName("http://tempuri.org/wsMobile", "getContentByAppID");
	protected static final QName _qname_getContentByAppIDResponse = new QName("http://tempuri.org/wsMobile", "getContentByAppIDResponse");
	protected static final QName _qname_getContentByAppIDResult = new QName("http://tempuri.org/wsMobile", "getContentByAppIDResult");
	protected static final QName _qname_getGamesByAppID = new QName("http://tempuri.org/wsMobile", "getGamesByAppID");
	protected static final QName _qname_getGamesByAppIDResponse = new QName("http://tempuri.org/wsMobile", "getGamesByAppIDResponse");
	protected static final QName _qname_getGamesByAppIDResult = new QName("http://tempuri.org/wsMobile", "getGamesByAppIDResult");
	protected static final Element _type_getGamesByAppID;
	protected static final Element _type_getGamesByAppIDResponse;
	protected static final Element _type_getContentByAppID;
	protected static final Element _type_getContentByAppIDResponse;
	static {
		// Create all of the Type's that this stub uses, once.
		Element _type_appID;
		_type_appID = new Element(_qname_appID, Type.INT);
		ComplexType _complexType_getGamesByAppID;
		_complexType_getGamesByAppID = new ComplexType();
		_complexType_getGamesByAppID.elements = new Element[1];
		_complexType_getGamesByAppID.elements[0] = _type_appID;
		_type_getGamesByAppID = new Element(_qname_getGamesByAppID, _complexType_getGamesByAppID);
		Element _type_GameID;
		_type_GameID = new Element(_qname_GameID, Type.INT);
		Element _type_Text;
		_type_Text = new Element(_qname_Text, Type.STRING, 0, 1, false);
		Element _type_CC;
		_type_CC = new Element(_qname_CC, Type.STRING, 0, 1, false);
		Element _type_ImgURL;
		_type_ImgURL = new Element(_qname_ImgURL, Type.STRING, 0, 1, false);
		ComplexType _complexType_mobileGame;
		_complexType_mobileGame = new ComplexType();
		_complexType_mobileGame.elements = new Element[4];
		_complexType_mobileGame.elements[0] = _type_GameID;
		_complexType_mobileGame.elements[1] = _type_Text;
		_complexType_mobileGame.elements[2] = _type_CC;
		_complexType_mobileGame.elements[3] = _type_ImgURL;
		Element _type_MobileGame;
		_type_MobileGame = new Element(_qname_MobileGame, _complexType_mobileGame, 0, -1, true);
		ComplexType _complexType_arrayOfMobileGame;
		_complexType_arrayOfMobileGame = new ComplexType();
		_complexType_arrayOfMobileGame.elements = new Element[1];
		_complexType_arrayOfMobileGame.elements[0] = _type_MobileGame;
		Element _type_getGamesByAppIDResult;
		_type_getGamesByAppIDResult = new Element(_qname_getGamesByAppIDResult, _complexType_arrayOfMobileGame, 0, 1, false);
		ComplexType _complexType_getGamesByAppIDResponse;
		_complexType_getGamesByAppIDResponse = new ComplexType();
		_complexType_getGamesByAppIDResponse.elements = new Element[1];
		_complexType_getGamesByAppIDResponse.elements[0] = _type_getGamesByAppIDResult;
		_type_getGamesByAppIDResponse = new Element(_qname_getGamesByAppIDResponse, _complexType_getGamesByAppIDResponse);
		_type_getContentByAppID = new Element(_qname_getContentByAppID, _complexType_getGamesByAppID);
		Element _type_URL;
		_type_URL = new Element(_qname_URL, Type.STRING, 0, 1, false);
		Element _type_Descripcion;
		_type_Descripcion = new Element(_qname_Descripcion, Type.STRING, 0, 1, false);
		Element _type_Status;
		_type_Status = new Element(_qname_Status, Type.BOOLEAN);
		ComplexType _complexType_mobileContent;
		_complexType_mobileContent = new ComplexType();
		_complexType_mobileContent.elements = new Element[3];
		_complexType_mobileContent.elements[0] = _type_URL;
		_complexType_mobileContent.elements[1] = _type_Descripcion;
		_complexType_mobileContent.elements[2] = _type_Status;
		Element _type_MobileContent;
		_type_MobileContent = new Element(_qname_MobileContent, _complexType_mobileContent, 0, -1, true);
		ComplexType _complexType_arrayOfMobileContent;
		_complexType_arrayOfMobileContent = new ComplexType();
		_complexType_arrayOfMobileContent.elements = new Element[1];
		_complexType_arrayOfMobileContent.elements[0] = _type_MobileContent;
		Element _type_getContentByAppIDResult;
		_type_getContentByAppIDResult = new Element(_qname_getContentByAppIDResult, _complexType_arrayOfMobileContent, 0, 1, false);
		ComplexType _complexType_getContentByAppIDResponse;
		_complexType_getContentByAppIDResponse = new ComplexType();
		_complexType_getContentByAppIDResponse.elements = new Element[1];
		_complexType_getContentByAppIDResponse.elements[0] = _type_getContentByAppIDResult;
		_type_getContentByAppIDResponse = new Element(_qname_getContentByAppIDResponse, _complexType_getContentByAppIDResponse);
	}
}
